package com.khyr.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.khyr.entity.Banner;
import com.khyr.entity.Menu;
import com.khyr.entity.News;
import com.khyr.entity.Notice;
import com.khyr.service.BannerService;
import com.khyr.service.MenuService;
import com.khyr.service.NoticeService;
import com.khyr.vo.BannnerVo;
import com.khyr.vo.NoticeVo;
import com.khyr.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;
    @Autowired
    private NoticeService noticeService;

    @GetMapping("/getPermissionByUserId/{userId}")
    public R<List<Menu>> getPermissionByUserId(@PathVariable Long userId){
        return menuService.getByUserId(userId);

    }
    @GetMapping("/getLeftMenu")//获取左侧菜单栏
    public R<List<Menu>> getLeftMenu(){
        return menuService.selectLeftMenuByUserId();
    }
    //获取轮播图
    @Autowired
    private BannerService bannerService;

    @GetMapping("/getBanner")
    public R<List<Banner>> getBanner(){
        return bannerService.getBanner();
    }
   // 公告条件查询加分页
    @PostMapping("/findNoticeByCond")
    public R<Page<Notice>> findNotice(@RequestBody NoticeVo noticeVo){
        return noticeService.findNotice(noticeVo);
    }
    //主页展示--查询所有可用的通知或公共
    @GetMapping("/selectAllNotice")
    public R<List<Notice>> selectAllNotice(){
        return noticeService.selectAllNotice();
    }
    //添加公共通知
    @PostMapping("/addNotice")
    public R addNotice(@RequestBody NoticeVo data){
        return noticeService.addNotice(data);
    }
    //修改公共通知
    @PostMapping("/updateNotice")
    public R updateNotice(@RequestBody NoticeVo data){
        System.out.println(data+"eeeeeeeeeeeeeeeeeeeeeeeeee");
        return noticeService.updateNotice(data);
    }
    //修改回显
    @PostMapping("/getNoticeByNoticeId/{noticeId}")
    public R getNoticeById(@PathVariable Integer noticeId){
        return noticeService.getNoticeById(noticeId);
    }
    //删除公共通知
    @DeleteMapping("/deleteNoticeByNoticeIds/{noticeIds}")
    public R deleteNoticeByNoticeIds(@PathVariable List<Integer> noticeIds){
        return noticeService.deleteNoticeByNoticeIds(noticeIds);
    }
    //前端-首页-获取轮播图
    @GetMapping("/getBanner2")
    public R<List<BannnerVo>> getBanner2(){
        return bannerService.getBanner2();
    }
    //健康新闻表
    @GetMapping("/getLittleNews")
    public R<List<News>> getLittleNews(){
        return noticeService.getLittleNews();
    }
    //根据新闻id 查看详情
    @GetMapping("/getNewsByNewsId/{newsId}")
    public R<News> getNewsByNewsId(@PathVariable String newsId){
        return noticeService.getNewsByNewsId(newsId);
    }




}